package com.yuanluludev.lib_pic.utils

import android.content.Context
import com.luck.picture.lib.basic.PictureSelector
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.interfaces.OnExternalPreviewEventListener
import com.yuanluludev.lib_pic.GlideEngine
import com.yuanluludev.lib_pic.bean.PicSelectorType
import com.yuanluludev.lib_pic.player.IjkPlayerEngine

/**
 * yuanLulu
 */
object PicPreviewUtils {

    /**
     * 预览图片、视频、音频
     */
    fun preview(
        context: Context,
        type: PicSelectorType,
        position: Int,
        mediaData: ArrayList<LocalMedia>,
        listener: OnExternalPreviewEventListener,
    ) {
        PictureSelector.create(context)
            .openPreview()
            .setImageEngine(GlideEngine.createGlideEngine())
            .apply {
                //暂时将视频播放引擎设置为null 后续可设置为IjkPlayerEngine() 但是需要添加so包 体积太大了11M
              //  if (type == PicSelectorType.TYPE_VIDEO || type == PicSelectorType.TYPE_IMAGE_VIDEO)
                //    setVideoPlayerEngine(IjkPlayerEngine())
            }
            .setExternalPreviewEventListener(listener)
            .startActivityPreview(position, true, mediaData)
    }

}